package com.demo.singleton;

/**
 * @Author: shubin_yao
 * @Date: 2022/05/10/21:37
 * @Description:
 * 懒汉模式: 线程安全
 * 缺点: synchronized 性能瓶颈
 */
public class Singleton_02 {

    private static Singleton_02 instance;

    private Singleton_02() {
        System.out.println("=======加synchronized的单例,构造方法Singleton_02");
    }

    public static synchronized Singleton_02 getInstance() {
        if (instance != null) return instance;
        instance = new Singleton_02();
        return instance;
    }

}
